home *** CD-ROM | disk | FTP | other *** search
- //wake in water particle shader
- //should be used with prtWake2.psh
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //input position:
- //x,y = side of particle (either -1 or 1)
- //z = size of particle
-
- //input vertex color:
- //a = alpha;
- //r(x) = x direction of wake
- //g(y) = y direction of wake
- //b = rotation angle of particle
-
- //input tex coord = position in space
-
- //world,view,projection transform
- float4x4 matViewProj;
-
- //shader input
- struct VS_INPUT
- {
- float4 Pos : POSITION;
- float4 Clr : COLOR;
- float2 Trans : TEXCOORD0;
- };
-
- //shader output
- struct VS_OUTPUT
- {
- float4 Pos : POSITION; //transformed out
- float2 Side : TEXCOORD0; //side of particle model is on (-1 to 1) (.xy)
- float4 Clr : COLOR;
- };
-
- //shader code
- VS_OUTPUT VShader(VS_INPUT In)
- {
- VS_OUTPUT Out;
-
- //rotate and scale particle (model space)
- In.Clr.b*=3.14159*2;
- float2x2 matRot={cos(In.Clr.b),sin(In.Clr.b),-sin(In.Clr.b),cos(In.Clr.b)};
- float4 pos;
- pos.xy=mul(matRot,In.Pos.xy)*In.Pos.z;
- pos.z=pos.w=1;
-
- //translate and transform it
- pos.xy+=In.Trans;
- Out.Pos=mul(matViewProj,pos);
-
- //copy model coords to side, and copy direction through
- Out.Side.xy=In.Pos.xy;
-
- //make color of wake
- Out.Clr=float4(1,1,1,In.Clr.a*0.6f);
-
- //spit out the results
- return Out;
- }
-